#define _CRT_SECURE_NO_WARNINGS 1
#include<vector>
#include<iostream>
using namespace std;

namespace leetcode 
{
    vector<int> twoSum(vector<int>& price, int target)
    {
        vector<int> ret;
        int left = 0;
        int right = price.size() - 1;
        while (left < right)
        {
            if (price[right] >= target)
            {
                right--;
            }
            else
            {
                if (price[left] + price[right] == target)
                {
                    ret.push_back(price[left]);
                    ret.push_back(price[right]);
                    break;
                }
                else
                {
                    if (price[left] + price[right] < target)
                        left++;
                    else
                        right--;
                }
            }
        }
        return ret;
    }
}
